#ifndef GSQUARE_H
#define GSQUARE_H

#include <iostream>
#include <string>
#include <fstream>

#include <QWidget>
#include <QPixmap>
#include <QGraphicsProxyWidget>
#include <QGraphicsPixmapItem>
#include <QGraphicsView>
#include <QPushButton>
#include <QButtonGroup>
#include <QLabel>
#include <QMessageBox>
#include <QTimer>
#include <QPropertyAnimation>
#include <QStateMachine>
#include <QApplication>
 #include <QInputDialog>
#include <QDir>
#include "gcase.h"
#include "playermanager.h"
#include "GameException.h"
#include "JudgeDredd.h"


class GSquare : public QWidget
{
    Q_OBJECT
public:
    explicit GSquare(QWidget *parent = 0);
    ~GSquare();

    const void setFond(QPixmap *pixmap);
    const void createMySquare();
    const void createPlayers();
    const void createMenu();
    void createOptions();



signals:
//    void myClicked(const int coord);
//    void button_pressed(int coord);

public slots:
    void button_pressed(QAbstractButton *sender);
    void button_released(QAbstractButton *sender);
    void end_of_box();
    void play();
    void changeIcon();
    void option();
    void changeIconOption();
    void changeIconQuit();
    void timeIa();
    void quitOpt();
    void quitGame();

private :
    int nb_col;
    int current_player;
    int ia;
    int _timeIa;
    int bt_time;
    int flag_opt;

	GameInfo	info;

    QGraphicsPixmapItem *fond;
    QGraphicsView *vw_square;
    QGraphicsScene *scene;
    QButtonGroup *group_pions;

    PlayerManager *j1;
    PlayerManager *j2;

    QMessageBox box;
    QGraphicsProxyWidget *proxy_btn;
    QPushButton *menu_btn;

    QGraphicsProxyWidget *proxy_opt;
    QPushButton *menu_opt;

    QGraphicsProxyWidget *proxy_optIa;
    QPushButton *menu_optIa;
    QPushButton *menu_optQuit;
    QGraphicsProxyWidget *proxy_optQuit;
    QGraphicsPixmapItem *item_time;
    QGraphicsPixmapItem *current_player_img;
    QGraphicsTextItem *proxy_score;

    QPushButton             *menu_quit;
    QGraphicsProxyWidget    *proxy_menuQuit;

    void check_result(int result);
    void change_currentPlayer();
    void change_btn_state(GCase *tmp_btn);
    void animation_victory();
    void hideMenu();
    void hideOption();
    void showMenu();
    void displayOptionGame();




};

#endif // GSQUARE_H
